import * as YvanUI from 'yvan-ui-wotu'

interface Ref {
    theform: YvanUI.Form
    t1: YvanUI.Text,
    t2: YvanUI.Text
}

const _ = YvanUI.lodash
const React = YvanUI.React
const {Switch} = YvanUI.Antd
const render = YvanUI.render

export default class DemoCascader extends YvanUI.Scope<void, Ref> {

    main = this.$$({
        t1: '',
    })

    vjson = {
        title: '层级示例',
        items: [
            {
                view: 'form',
                debug: 'main',
                ref: 'theform',
                items: [
                    {
                        view: 'card',
                        rows: [
                            {
                                cols: [
                                    {
                                        view: 'cascader',
                                        bind: 'main.t1',
                                        label: '类目',
                                        required: true,
                                        data: [
                                            {label: "w1", value: "w1", parentValue: ""},
                                            {label: "w2", value: "w2", parentValue: "w1"},
                                            {label: "w3", value: "w3", parentValue: "w2"},
                                            {label: "w4", value: "w4", parentValue: "w1"},
                                            {label: "w5", value: "w5", parentValue: ""},
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ],

            }
        ],
        footer: [
            {
                view: 'button',
                text: '校验',
                type: 'primary',
                onClick: () => {
                    this.refs.theform.validateFields().then(() => {
                    })
                }
            }
        ]
    }
}